We set the path to the config.cfg file using the environment variable 'PYPMJ_CONFIG_FILE'. If you do not have a configuration file yet, please look into the Setting up a configuration file example.
In [ ]:
import os
os.environ['PYPMJ_CONFIG_FILE'] = '/path/to/your/config.cfg'
Now we can import pypmj
and numpy
. Since the parent directory, which contains the pypmj module, is not automatically in our path, we need to append it before.
In [ ]:
import sys
sys.path.append('..')
import pypmj as jpy
import numpy as np
Load the materials extension.
In [ ]:
jpy.load_extension('materials')
The materials extension provides access to tabulated and formula-based optical material property data. It can load such data from different data bases, extract additional information such as citations, as well as automatically interpolate, extrapolate and plot the data.
The functionality is provided by the class MaterialData
.
In [ ]:
jpy.MaterialData?
Note: The current implementation is a bit inflexible/incomplete and will probably be changed/completed in a future version.
There is currently only access to the following materials, although adding more materials is easily done by extending this dict in the materials.py
file:
In [ ]:
jpy.MaterialData.materials.keys()
We show the abilities using the gallium arsenide data set.
In [ ]:
GaAs = jpy.MaterialData(material = 'gallium_arsenide')
Get some metadata:
In [ ]:
GaAs.getAllInfo()
The default for unitOfLength
is 1.
, which defaults to meter. We can get refractive index data (here called $n$-$k$-data, where $n$ is the real and $k$ the imaginary part of the complex refractive index) for specific wavelengths like this
In [ ]:
wvl = 600.e-9 # = 600nm
GaAs.getNKdata(wvl)
Or for multiple wavelengths values
In [ ]:
wvls = np.linspace(600.e-9, 1000.e-9, 6) # = 600nm to 1000nm
GaAs.getNKdata(wvls)
Or we can get the permittivity.
In [ ]:
GaAs.getPermittivity(wvls)
We can also plot the complete known data to get an overview of the data set.
In [ ]:
%matplotlib inline
import matplotlib.pyplot as plt
plt.figure(figsize=(8,6))
GaAs.plotData()
Or we can plot data in a specific wavelength range, thistime also showing the known (tabulated) points to show case the interpolation.
In [ ]:
plt.figure(figsize=(8,6))
GaAs.plotData(wvlRange=(200.e-9, 1000.e-9), plotKnownValues=True)